package mbp.agents;

import java.util.Iterator;

import mbp.core.Intention;
import mbp.core.Offer;
import mbp.core.ServiceTypeBuilder;

/**
 * Agent zadania - PROSTA IMPLEMETACJA
 * @author Wojciech Wilanski
 *
 */
public class MbpTaskAgent extends AMbpTaskAgent 
{

	@Override
	public Intention prepareIntention() {
		ServiceTypeBuilder stb = new ServiceTypeBuilder("");
		
		Intention intn = new Intention(stb.GetServiceType( serverList.get(0).type ));
		intn.getResourcesOut().get(0).setCondition(new String(rcv.getCondition()));
		intn.getResourcesOut().get(0).setQuantity(new Integer( rcv.getQuantity()));
		intn.setRealizeMaxTU(new Integer(rcv.integerValue));
		logger.warn("type: " + intn.getServiceType().getServiceTypeName() + " quantity:" + intn.getResourcesOut().get(0).getQuantity() + " term:" + intn.getRealizeMaxTU());
		intn.setClientName(new String(getLocalName()));
		return intn;
	}

	@Override
	public Decision decision() {
		if(offerList.isEmpty())
		{
			return Decision.REJECT;
		}
		else
		{
			return Decision.ACCEPT;
		}
	}

	@Override
	public Offer selectBestOffer() {
		
		if(offerList.isEmpty()) {
			return null;
		}
		else {
			Iterator<String> it = offerList.keySet().iterator();
			String key = it.next();
			return offerList.get(key);
		}
	}

	@Override
	public Intention prepareCounterOffer() {
		// TODO Auto-generated method stub
		return null;
	}

}
